package cn.kai.controller;


import cn.kai.base.JsonResult;
import cn.kai.service.SysProductService;
import cn.kai.vo.SysProductVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 产品表 前端控制器
 * </p>
 *
 * @author autoCode
 * @since 2025-03-08 05:14:07
 */
@RestController
@RequestMapping("/api/v1/product")
@Api(tags = "产品")
@RequiredArgsConstructor
public class SysProductController {
    private final SysProductService productService;

    @PostMapping("/upload-product")
    @ApiOperation("上传产品excel")
    public JsonResult uploadProductExcel(@RequestBody MultipartFile file){
        return productService.uploadProductExcel(file);
    }

    @GetMapping("/query-product")
    @ApiOperation(value = "查询产品",notes = "名称模糊查询")
    private JsonResult<List<SysProductVO>> queryProduct(@RequestParam String name){
        return JsonResult.buildSuccess(productService.queryProduct(name));
    }

    @GetMapping("/get-product-info")
    @ApiOperation("获取产品详情信息")
    private JsonResult<SysProductVO> getProductInfo(@RequestParam @ApiParam("产品id") Long id){
        return JsonResult.buildSuccess(productService.getProductInfo(id));
    }
}

